﻿@{
    ViewBag.Title = "美食菜品";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@using mscook.mvc;
@model mscook.mvc.Models.CookBookModel

@section JavaScript
{
    <script src="BootStrap/js/jquery-ui.min.js"></script>
    <script src="Carousel/allinone_thumbnailsBanner.js"></script>
    <script src="Carousel/jquery.featureCarousel.js"></script>
    <script type="text/javascript">
        $(function () {
            var $w = $(window);
            var $scr_wid = $(window).width();
            var $w_height = $w.height();
            var acc_min_width;//accordion
            var feature_width, feature_height, feature_pad_side;//3DfeatureCarousel

            //左侧菜单随屏幕滚动
            if ($scr_wid >= 1024) {
                setTimeout(function () {
                    var top = $('.recipes_menu').offset().top;
                    $('.recipes_menu').affix({
                        offset: {
                            top: function () { return $w.width() <= 980 ? 290 : top }
                        , bottom: 775
                        }
                    })
                }, 100)
            }

            (function () {
                $('body').animate({ scrollTop: $('.navbar').offset().top }, 1000);
            })();//友好的页面显示，全局作用

            $.getJSON("Home/SelectImageSetting", function (config) {
                var folder;
                var $scr_wid = $(window).width();
                var banner_wid;
                var banner_hei;
                var screen_num;
                function hasFolder(set, folder) {
                    var image_setting = null;
                    $.each(set, function (i, elem) {
                        if (elem.folder == folder) {
                            image_setting = elem;
                            return false;
                        }
                    });
                    return image_setting;
                }
                $.each(config, function (i, item) {
                    //alert(config[i].name);
                    var images = config[i].ImageSettings;
                    //alert(images.folder);
                    //var img_fol = images.folder;
                    if (images != null && images.length != 0) {
                        var image_setting;
                        if ($scr_wid >= 1200 && (image_setting = hasFolder(images, "wide")) !== null) {
                            folder = "wide";
                            acc_min_width = "115px";
                            banner_wid = image_setting.width;
                            banner_hei = image_setting.height;
                            screen_num = 7;
                            //feature_width = 450;
                            //feature_height = 230;

                        } else if ($scr_wid >= 768 && $scr_wid <= 979 && (image_setting = hasFolder(images, "pad")) !== null) {
                            folder = "pad";
                            acc_min_width = "30px";
                            banner_wid = image_setting.width;
                            banner_hei = image_setting.height;
                            screen_num = 5;
                            //feature_width = 340;
                            //feature_height = 174;


                        } else if ($scr_wid < 768 && (image_setting = hasFolder(images, "mobile")) !== null) {
                            folder = "mobile";
                            acc_min_width = "20px";
                            banner_wid = image_setting.width;
                            banner_hei = image_setting.height;
                            screen_num = 7;


                        } else {
                            image_setting = hasFolder(images, "default");
                            folder = "default";
                            acc_min_width = "70px";
                            banner_wid = image_setting.width;
                            banner_hei = image_setting.height;
                            screen_num = 7;
                            //feature_width = 450;
                            //feature_height = 230;
                        }
                        $('div[data-image-setting=' + config[i].alias + '] img').each(function (i, img) {
                            var $img = $(img);

                            var $slide_li = $img.parent();
                            var source = $img.data("source");
                            if (source) {
                                var data = "Upload/" + folder + "/" + source;
                                if (data) {
                                    $img.attr("data-src", data);
                                    $slide_li.attr("data-bottom-thumb", data);
                                }
                            }
                            $img.unveil();


                        });




                    }

                })



                //Input placeholder

                //3D Carousel

                //jQueryUI Widgets ——tabs
                $("#material").tabs({
                    event: "mouseover",
                    selected: 1
                });
                //
                var hdw = $('#material ul li');
                hdw.hover(function () {
                    $(this).addClass('active_back').siblings().removeClass('active_back');
                });
                //Bootstrap carousel
                $('.carousel').carousel({
                    interval: 2000
                })
                //accordion

            });
        });

    </script>

    @Html.Partial("_ResourceTypeSelect")
}

<div class="container marketing">


    <!-- title -->
    <div class="last_title visible-phone">
        <h3 class="span3 clearfix textline">
            <a href="#">[新闻精选]</a>
        </h3>
    </div>
    <div class="last_title hidden-phone">
        <div class="row">
            <h3 class="span3 offset3" style="line-height: 50px">你应该知道的</h3>
            <h1 class="span3">热点新闻</h1>

        </div>
    </div>
    <hr class="featurette-divider" />
    <!-- recipes -->

    <div class="row recipes " onselectstart="return false">
        <div class="span3">
            <div class="row">
                <div class="recipes_menu span3">
                    <div class="menu_til">
                        <h4>新闻筛选</h4>
                    </div>
                    @Html.Partial("_ResourceType")
                </div>
            </div>
        </div>
        <div class="span9" data-image-setting="CookBook">
            <div class="row">

                @for (int i = 0; i < Model.CookBookList.Count; i++)
                {
                    var item = Model.CookBookList.ElementAt(i);
                    <div class="span3 list ">
                        <div class="img">
                            <a target="" href="javaScript:void(0)">
                                <img src="lazyload/grey.gif" data-source="@item.ImageName" /></a>
                        </div>
                        <div class="info2">
                        </div>
                        <div class="mag_info1">
                            <div class="mag_in_til">
                                <h4>
                                    <a href="#">@Html.Encode(item.Name)</a>
                                </h4>
                                @{
                    bool isNull = item.Chef == null;
                               
                                    <a href="@Html.Encode(isNull ? "#" : Url.Action("readchef", "chef", new {id=item.Chef.Id }))" class="">新闻报道:@Html.Encode(isNull?"览月齐鲁":item.Chef.Name)</a>
                                
                                }
                            </div>

                            @if (item.ResourceBonusSetting == null || item.ResourceBonusSetting.Bonus == 0 || (Model.LoginUser != null && (Model.LoginUser.IsVip || Model.LoginUser.hasPurchased(item.Id))))
                            {
                                <a href="@Url.Action("ReadCookBook", new { id = item.Id })" class="btn s_but">查看详细</a>
                            }
                            else
                            {
                                if (Model.LoginUser == null)
                                {
                                <a href="#dialog-form-login" data-toggle="modal" class="btn s_but">登录后查看</a>
                                }
                                else
                                {
                                <a href="#" data-url="@Url.Action("ReadCookBook", new { id = item.Id })" data-bonus="@item.AbsBonus" data-message="@Html.Encode("您确定要购买" + (item.Chef == null ? "" : ("由 " + item.Chef.Name + " 创作的 ")) + item.Name)" data-resource="@item.Id" class="btn needBonus s_but">支付积分并查看</a>
                                }
                            }

                        </div>
                    </div>
                }

            </div>
            @Html.Partial("_PageBreak")
        </div>
    </div>
</div>
